﻿@model PeshoMVC.Models.UserProfileModel

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.Title = "Change picture";
}

<h2>Change picture</h2>

@using (Html.BeginForm("ChangePicture", "User", FormMethod.Post, new { @class = "form-horizontal", enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()

    @Html.HiddenFor(model => model.UserId)

    <div class="form-group">
        @Html.LabelFor(model => model.Picture, new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            <img src="@Url.Action("GetImage", "User", new { User.Identity.Name })" alt="Missing picture!" width="280px" />
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="file" name="file"><br />
            <input type="submit" value="Upload" class="btn btn-default" /> |
            @Html.ActionLink("Back to List", "Edit", new { id = Model.UserId })
            @if (Roles.IsUserInRole(User.Identity.Name, "admin"))
            {
               <span> | </span> @Html.ActionLink("Back to user panel", "Index", "ManageUsers", new { area = "Admin" }, null)
            }
        </div>
    </div>

    if (ViewBag.Error != null)
    {
        <div class="alert alert-danger alert-dismissable">
            @ViewBag.Error
        </div>
    }
    if (ViewBag.Message != null)
    {
        <div class="alert alert-success alert-dismissable">
            @ViewBag.Message
        </div>
    }
}